package pro.lepers.portfolio.view.contents.portfolio.data.contents {
	import flash.utils.Dictionary;

	/**
	 * @author Pierre Lepers
	 */
	public class ProjectContentFactory {

		
		public static function getContentData( datas : XML ) : AbstractContentData {
			
			var type:  String = datas.@type;
			
			var dClass : Class = _map[ type ];
			if( dClass == null )
				throw new Error( "ProjectContentFactory Error : unknown type '"+type+"'" );
				
			var res : AbstractContentData = new dClass( ) as AbstractContentData;
			res._parse( datas );
			
			return res;
		}

		private static var _map : Dictionary = _cinit_map();

		private static function _cinit_map() : Dictionary {
			var res : Dictionary = new Dictionary();
			
			res[ AbstractContentData.IMGS ] = ImagesContentData;
			res[ AbstractContentData.TEXT ] = TextContentData;
			res[ AbstractContentData.SWF ] = SwfContentData;
			res[ AbstractContentData.VIDEO ] = VideoContentData;
			
			return res;
		}
		
	}
}
